package com.tac.controller.wms;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.wms.CarrierOrder;
import com.tac.service.wms.CarrierOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/carrierOrder")
@Api(tags = "智能仓储WMS--运输管理--承运申请")
@CrossOrigin
public class CarrierOrderController {

    @Autowired
    private CarrierOrderService carrierOrderService;

    /**
     * 查询
     * @param pageNum 当前页数
     * @param pageSize 每页显示数目
     * @param documentNumber 单据编号
     * @param outboundOrderNumber 出库单编号
     * @param shippingNumber 发货单号
     * @param customer 客户
     * @return
     */
    @GetMapping("/getList")
    @ApiOperation("承运单接口查询")
    public Result<PageInfo<CarrierOrder>> getList(@RequestParam(defaultValue = "1") Integer pageNum,
                                                  @RequestParam(defaultValue = "10") Integer pageSize,
                                                  @RequestParam(required = false) String documentNumber,
                                                  @RequestParam(required = false) String outboundOrderNumber,
                                                  @RequestParam(required = false) String shippingNumber,
                                                  @RequestParam(required = false) String customer) {
        return carrierOrderService.getList(pageNum, pageSize, documentNumber, outboundOrderNumber, shippingNumber, customer);
    }

    /**
     * 添加
     * @param carrierOrder
     * @return
     */
    @PostMapping("/save")
    @ApiOperation("承运单接口添加")
    public Result save(@RequestBody CarrierOrder carrierOrder) {
        return carrierOrderService.save(carrierOrder);
    }

    /**
     * 删除
     * @param ids
     * @return
     */
    @DeleteMapping("/remove")
    @ApiOperation("承运单接口删除")
    public Result delete(@RequestBody List<Integer> ids) {
        return carrierOrderService.remove(ids);
    }

    /**
     * 更新
     * @param carrierOrder
     * @return
     */
    @PutMapping("/update")
    @ApiOperation("承运单接口更新")
    public Result update(@RequestBody CarrierOrder carrierOrder) {
        return carrierOrderService.update(carrierOrder);
    }

}
